<!-- This HTML file has been created by texi2html 1.29
     from ext2fs.texi on 3 August 1994 -->

<TITLE>Analysis of the Ext2fs structure - Inodes</TITLE>
<P>Go to the <A HREF="ext2fs_6.html">previous</A>, <A HREF="ext2fs_8.html">next</A> section.<P>
<A NAME="IDX27"></A>
<H1><A NAME="SEC7" HREF="ext2fs_toc.html#SEC7">Inodes</A></H1>
<A NAME="IDX28"></A>
<A NAME="IDX29"></A>
<A NAME="IDX30"></A>
<A NAME="IDX31"></A>
<A NAME="IDX32"></A>
<A NAME="IDX33"></A>
<P>
An inode uniquely describes a file. Here's what an inode looks like on
disk:
<P>
<PRE>
struct ext2_inode {
  unsigned short i_mode;
  unsigned short i_uid;
  unsigned long  i_size;
  unsigned long  i_atime;
  unsigned long  i_ctime;
  unsigned long  i_mtime;
  unsigned long  i_dtime;
  unsigned short i_gid;
  unsigned short i_links_count;
  unsigned long  i_blocks;
  unsigned long  i_flags;
  unsigned long  i_reserved1;
  unsigned long  i_block[EXT2_N_BLOCKS];
  unsigned long  i_version;
  unsigned long  i_file_acl;
  unsigned long  i_dir_acl;
  unsigned long  i_faddr;
  unsigned char  i_frag;
  unsigned char  i_fsize;
  unsigned short i_pad1;
  unsigned long  i_reserved2[2];
};
</PRE>
<P>
<DL COMPACT>
<DT><CODE>i_mode</CODE>
<DD>type of file (character, block, link, etc.) and access rights on the
file.
<P>
<DT><CODE>i_uid</CODE>
<DD>uid of the owner of the file.
<P>
<DT><CODE>i_size</CODE>
<DD>logical size in bytes.
<P>
<DT><CODE>i_atime</CODE>
<DD>last time the file was accessed.
<P>
<DT><CODE>i_ctime</CODE>
<DD>last time the inode information of the file was changed.
<P>
<DT><CODE>i_mtime</CODE>
<DD>last time the file content was modified.
<P>
<DT><CODE>i_dtime</CODE>
<DD>when this file was deleted.
<P>
<DT><CODE>i_gid</CODE>
<DD>gid of the file.
<P>
<DT><CODE>i_links_count</CODE>
<DD>number of links pointing to this file.
<P>
<DT><CODE>i_blocks</CODE>
<DD>number of blocks allocated to this file counted in 512 bytes units.
<P>
<DT><CODE>i_flags</CODE>
<DD>flags (see below).
<P>
<DT><CODE>i_reserved1</CODE>
<DD>reserved.
<P>
<DT><CODE>i_block</CODE>
<DD>pointers to blocks (see below).
<P>
<DT><CODE>i_version</CODE>
<DD>version of the file (used by NFS).
<P>
<DT><CODE>i_file_acl</CODE>
<DD>control access list of the file (not used yet).
<P>
<DT><CODE>i_dir_acl</CODE>
<DD>control access list of the directory (not used yet).
<P>
<DT><CODE>i_faddr</CODE>
<DD>block where the fragment of the file resides.
<P>
<DT><CODE>i_frag</CODE>
<DD>number of the fragment in the block.
<P>
<DT><CODE>i_size</CODE>
<DD>size of the fragment.
<P>
<DT><CODE>i_pad1</CODE>
<DD>padding.
<P>
<DT><CODE>i_reserved2</CODE>
<DD>reserved.
</DL>
<P>
As you can see, the inode contains, <CODE>EXT2_N_BLOCKS</CODE> (15 in ext2fs
0.5) pointers to block. Of theses pointers, the first
<CODE>EXT2_NDIR_BLOCKS</CODE> (12) are direct pointers to data. The following entry
points to a block of pointers to data (indirect). The following entry
points to a block of pointers to blocks of pointers to data (double
indirection). The following entry points to a block of pointers to a
block of pointers to a block of pointers to data (triple indirection).
<P>
The inode flags may take one or more of the following or'ed values:
<P>
<DL COMPACT>
<DT><CODE>EXT2_SECRM_FL 0x0001</CODE>
<DD>secure deletion. This usually means that when this flag is set and we
delete the file, random data is written in the blocks previously allocated
to the file.
<P>
<DT><CODE>EXT2_UNRM_FL 0x0002</CODE>
<DD>undelete. When this flag is set and the file is being deleted, the file
system code must store enough information to ensure the undeletion of
the file (to a certain extent).
<P>
<DT><CODE>EXT2_COMPR_FL 0x0004</CODE>
<DD>compress file. The content of the file is compressed, the file system
code must use compression/decompression algorithms when accessing the
data of this file.
<P>
<DT><CODE>EXT2_SYNC_FL 0x0008</CODE>
<DD>synchronous updates. The disk representation of this file must be kept
in sync with it's in core representation. Asynchronous I/O on this kind
of file is not possible. The synchronous updates only apply to the inode
itself and to the indirect blocks. Data blocks are always written
asynchronously on the disk.
</DL>
<A NAME="IDX34"></A>
<A NAME="IDX35"></A>
<A NAME="IDX36"></A>
<A NAME="IDX37"></A>
<A NAME="IDX38"></A>
<A NAME="IDX39"></A>
<A NAME="IDX40"></A>
<A NAME="IDX41"></A>
<A NAME="IDX42"></A>
<P>
Some inodes have a special meaning:
<P>
<DL COMPACT>
<DT><CODE>EXT2_BAD_INO 1</CODE>
<DD>a file containing the list of bad blocks on the file system.
<P>
<DT><CODE>EXT2_ROOT_INO 2</CODE>
<DD>the root directory of the file system.
<P>
<DT><CODE>EXT2_ACL_IDX_INO 3</CODE>
<DD>ACL inode.
<P>
<DT><CODE>EXT2_ACL_DATA_INO 4</CODE>
<DD>ACL inode.
<P>
<DT><CODE>EXT2_BOOT_LOADER_INO 5</CODE>
<DD>the file containing the boot loader. (Not used yet it seems.)
<P>
<DT><CODE>EXT2_UNDEL_DIR_INO 6</CODE>
<DD>the undelete directory of the system.
<P>
<DT><CODE>EXT2_FIRST_INO 11</CODE>
<DD>this is the first inode that does not have a special meaning.
</DL>
<P>
<P>Go to the <A HREF="ext2fs_6.html">previous</A>, <A HREF="ext2fs_8.html">next</A> section.<P>
